package org.goochasca

final class PieChart private(
  width: Int, height: Int,
  is3D: Boolean = false,
  angleRadians: Float = 0.0f,
  data: Seq[Data]
) extends Chart(width, height, 0 to Utils.maxDataPoint(data), data)
with Title with Labels with Colors
{
    
  require(!is3D || data.size == 1, "Concentric 3D pies are not supported")

  def this(width: Int, height: Int, data: Data*) = this(width, height, data=data)
  def this(width: Int, height: Int, is3D: Boolean, data: Data*) = this(width, height, is3D, data=data)
  def this(width: Int, height: Int, angle: Float, data: Data*) = this(width, height, angleRadians=angle, data=data)
  
  protected val chartType = 
    if (data.size > 1)
      "pc"
    else if (is3D)
      "p3"
    else
      "p"
        
  protected override def appendParms(sb: StringBuilder) {
    super.appendParms(sb)
    if (angleRadians != 0.0f) 
      sb append "&chp=" append angleRadians
  }
}
